package com.efast.cafe.portal.service.query.defauleValue;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.efast.cafe.framework.util.QueryStringUtil;


@SuppressWarnings("all")
public abstract class AbstractConditionValue<T,EXT> extends BaseConditionValue{
	private T t;
	
	public AbstractConditionValue() {
		
	}
	abstract Object getObject();
	
	abstract String getShortName();
	
	
	
	public Object getFieldValue(String fieldName,Object objectTarget) {
		Field field;
		try {
			Class class1 = objectTarget.getClass();
			Method method = class1.getDeclaredMethod("get"+QueryStringUtil.capitalize(fieldName));
			return method.invoke(objectTarget);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	public String gethandledValue (String fieldName) {
		init();
		Object object = getObject();
		Object value = getFieldValue(fieldName, object);
		String string = "";
		if (value instanceof String) {
			string = QueryStringUtil.changeToString(value.toString());
		} else {
			string = value.toString();
		}
		return string;
	}
	public T getT() {
		return t;
	}
	public void setT(T t) {
		this.t = t;
	}
	
}
